# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: rudy.matela

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - set -DZ3_LINK_TIME_OPTIMIZATION=OFF

pkgbase=z3
pkgname=('z3' 'python-z3')
pkgver=4.8.10
pkgrel=1
pkgdesc='High-performance theorem prover'
url='https://github.com/Z3Prover/z3'
arch=('x86_64')
license=('MIT')
 # 'java-environment-common' 'mono' 'ocaml' 'ocaml-findlib'
makedepends=('cmake' 'python' 'python-setuptools' 'gcc-libs')
source=(https://github.com/Z3Prover/z3/archive/z3-${pkgver}.tar.gz)
sha512sums=('d2741d7ad3e1d5ee3fec92095b061a96a700c3327b2eb2090d4162bdcaeaebca8c072ef79c5daac1f6de3456165c2cc38e13f1045bc707779d1027b943837c5b')

prepare() {
  cd ${pkgbase}-z3-${pkgver}
  mkdir -p build
}

build() {
  cd ${pkgbase}-z3-${pkgver}/build
  cmake .. \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DZ3_LINK_TIME_OPTIMIZATION=OFF \
    -DZ3_BUILD_PYTHON_BINDINGS=1 \
    -DPYTHON_EXECUTABLE=/usr/bin/python
  make
}

package_z3() {
  depends=('gcc-libs')
  provides=('libz3' 'libz3.so')
  cd ${pkgbase}-z3-${pkgver}/build
  make DESTDIR="${pkgdir}" install
  install -Dm 644 ../LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
  rm -r "${pkgdir}"/usr/lib/python*
}

package_python-z3() {
  depends=('python' 'z3')
  cd ${pkgbase}-z3-${pkgver}/build
  make DESTDIR="${pkgdir}" install
  install -Dm 644 ../LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
  cd "${pkgdir}"
  rm -r usr/include usr/bin usr/lib/{cmake,pkgconfig,lib*}
  python -m compileall .
  python -O -m compileall .
}

# vim: ts=2 sw=2 et:
